﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLy_NhaSach
{
    public partial class QuanLyNV : Form
    {
        public QuanLyNV()
        {
            InitializeComponent();
        }

        private void nhanVienBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.nhanVienBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.nhaSachDataSet);

        }

        private void QuanLyNV_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'nhaSachDataSet.NhanVien' table. You can move, or remove it, as needed.
            //this.nhanVienTableAdapter.Fill(this.nhaSachDataSet.NhanVien);
            nhanVienBindingSource.DataSource = NhaSachBUS.NhanVienBUS.LoadNhanVien();

        }

        private void tabPage2_Click(object sender, EventArgs e)
        {

        }

        private void soDienThoaiLabel_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            CloseForm();
        }

        private void CloseForm()
        {
            this.Dispose();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            NhaSachBUS.NhanVienBUS.XoaNhanVien(int.Parse(maNVTextBox.Text));
            nhanVienBindingSource.DataSource = NhaSachBUS.NhanVienBUS.LoadNhanVien();
        }

        private void Them_Click(object sender, EventArgs e)
        {
            NhaSachBUS.NhanVienBUS.ThemNhanVien(int.Parse(txtmanv.Text), txthotennv.Text, txtgioitinh3.Text,Convert.ToDateTime(txtdatetime.Text), txtdiachi.Text, txtcmnd.Text, txttaikhoan.Text, txtchucvu.Text, txtcatruc.Text, txtsdt.Text, txtemail.Text, float.Parse(txtluongcb.Text));
            nhanVienBindingSource.DataSource = NhaSachBUS.NhanVienBUS.LoadNhanVien();
        }

        private void capnhat_Click(object sender, EventArgs e)
        {
            NhaSachBUS.NhanVienBUS.CapNhatNhanVien(int.Parse(maNVTextBox.Text), hoTenNVTextBox.Text, gioiTinhTextBox.Text, Convert.ToDateTime(ngaySinhDateTimePicker.Text), diaChiTextBox.Text, cMNDTextBox.Text, soTaiKhoanTextBox.Text, chucVuTextBox.Text, soDienThoaiTextBox.Text); 
            nhanVienBindingSource.DataSource = NhaSachBUS.NhanVienBUS.LoadNhanVien();
        }
    }
}
